import 'package:flutter/material.dart';

class Widget_DecoratedBox_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_DecoratedBox_State();
  }
}

class Widget_DecoratedBox_State extends State<Widget_DecoratedBox_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(title: Text("DecoratedBox组件"),),
          body: DecoratedBox(
            decoration: new BoxDecoration(
                color: Color(0x6600ff00),
                border: Border.all(
                    color: Color(0xff0000ff)
                ),
                borderRadius: BorderRadius.circular(10.0),
            ),
            position: DecorationPosition.foreground,
//            position: DecorationPosition.background,
            child: Container(
              padding: EdgeInsets.all(50.0),
              child: Container(
                width: 200.0,
                height: 200.0,
                color: Color(0xffff0000),
              ),
            ),
          )
      ),
    );
  }
}

/**
 * 在子控件绘制之前或之后绘制一个装饰
    const DecoratedBox({
    Key key,
    @required this.decoration,//要绘制的装饰器
    this.position = DecorationPosition.background,//绘制在子组件上面(DecorationPosition.background)还是下面(DecorationPosition.foreground)
    Widget child
    })
 */
